Skip to content

chore: Fix unexpected connection-pool shut-down - #1095

Open
newtork wants to merge 24 commits into
mainfrom
fix-connection-pool-shut-down
Open

chore: Fix unexpected connection-pool shut-down#1095
newtork wants to merge 24 commits into
mainfrom
fix-connection-pool-shut-down

Conversation

@newtork

@newtork newtork commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Context

Related

I was wondering whether the following rule always holds true...?

Tenant+Destination 1 <-> 1 (Cloud SDK) HttpClient 1 <-> 1 Connection Manager 1 <-> 1 Connection Pool

I thought that would be correct, until I realized there's one exception in HttpClientWrapper.
The following method creates a new HttpClient and inherits the connection-pool implicitly:

HttpClientWrapper withDestination( final HttpDestinationProperties destination )
{
// explicitly check the reference equality, since equals doesn't check header providers
// this is a slight improvement, avoiding unnecessary wrapper instantiation
// in cases where destination objects are reused / served from cache
if( !destination.equals(this.destination) ) {
throw new ShouldNotHappenException(
"This method must not be used outside of updating an instance of HttpClientWrapper for http clients served from the HttpClientCache.");
}
if( destination == this.destination ) {
return this;
}
return new HttpClientWrapper(httpClient, destination);
}

I'm able to reproduce the reported bug.
That even can explain the observed behavior from garbage collector.

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@newtork
newtork marked this pull request as draft February 11, 2026 16:10
@newtork newtork added the bug Something isn't working label Apr 27, 2026
@CharlesDuboisSAP
CharlesDuboisSAP marked this pull request as ready for review August 4, 2026 12:50
@CharlesDuboisSAP CharlesDuboisSAP self-assigned this Aug 4, 2026
@CharlesDuboisSAP CharlesDuboisSAP added please merge Request to merge a pull request please review Request to review a pull request labels Aug 4, 2026
@CharlesDuboisSAP CharlesDuboisSAP changed the title chore: Fix unexpected connection-pool shut-down of HttpClient4 chore: Fix unexpected connection-pool shut-down Aug 4, 2026

@Jonas-Isr Jonas-Isr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM :)

Comment on lines +584 to +587
customHeaderProviders
.forEach(
provider -> builder
.append(provider, that.customHeaderProviders.get(customHeaderProviders.indexOf(provider))));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question)

Isn't this just equals to the following?

  for (int i = 0; i < customHeaderProviders.size(); i++) {
      builder.append(customHeaderProviders.get(i), that.customHeaderProviders.get(i));
  }

return false;
}

val builder =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Very Minor)

To stay consistent.

Suggested change
val builder =
final var builder =

.append(resolveKeyStoreHashCode(keyStoreSupplier.get().getOrNull()))
.append(resolveKeyStoreHashCode(trustStore))
.toHashCode();
val builder =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Very Minor)

To stay consistent.

Suggested change
val builder =
final var builder =


@Test
//This is a known limitation of excluding header providers in the equality check of destinations
void testGetClientReturnsSameClientForDestinationsWithOnlyDifferentHeaderProviders()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question)

Why is this test still green? Shouldn't it fail given the comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working please merge Request to merge a pull request please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants